<template>
	<section>
		<!--后勤未签收列表-->
		<el-table :data="logistics" border v-loading="logisticsLoading" class="logistics-list">
			<el-table-column type="index" width="60">
			</el-table-column>
			<el-table-column prop="Category" label="申请类型" width="120">
			</el-table-column>
			<el-table-column prop="Applicant" label="申请人" min-width="120">
			</el-table-column>
			<!--<el-table-column prop="Mobile" label="申请人电话" width="150">-->
			<!--</el-table-column>-->
			<el-table-column label="用餐时间" min-width="240">
				<template scope="scope">
					<p>{{scope.row.VisitDate | moment}} <strong style="color: #FFA500;">{{scope.row.MealType}}</strong></p>
				</template>
			</el-table-column>
			<el-table-column label="用餐人数" min-width="100">
				<template scope="scope">
					<p>{{scope.row.MealNum}}人</p>
				</template>
			</el-table-column>
			<el-table-column prop="Room" label="用餐地点" min-width="120">
			</el-table-column>
			<el-table-column label="用餐标准" min-width="100">
				<template scope="scope">
					<p>{{scope.row.Price}}元</p>
				</template>
			</el-table-column>
			<el-table-column prop="Status" label="状态" width="100">
			</el-table-column>
			<el-table-column label="操作" width="80">
				<template scope="scope">
					<el-button type="primary"  size="small" @click="fnSignoff(scope.row.ID)">签收</el-button>
				</template>
			</el-table-column>
		</el-table>
	</section>
</template>

<script>
    import Svc from '../../service/index.js'
    import moment from 'moment'
	export default {
		data() {
			return {
				logisticsLoading:false,
				logistics:[]
			}
		},
//        beforeMount() {
//            //设置定时器，每10秒刷新一次
//            var that = this;
//            setInterval(function () {
//                that.fnGetLogistics()
//				that.lastTime = (Date.parse(new Date()))/1000
//            },10000)
//        },
		methods: {
			//显示message提示框
            openMessage : function(msg,type){
    	        this.$message({
		          	showClose: true,
		          	message: msg,
		          	type: type
		        });
            },
            //格式化->来访人员
            fnVisitorFormat(row, column){
            	var list = row[column.property] || [];
            	var res = ''
            	for (var i=0;i<list.length;i++) {
            		if (i == list.length-1) {
            			res += list[i]
            			continue
            		}
            		res += list[i] + "、"
            	}
            	return res
            },
			//获取后勤未签收列表
			fnGetLogistics () {
				var that = this
				that.logisticsLoading = true
				var params = {
						LastTime : 0
				}
				Svc.fnPostData('/api/meal/pendingsignoff',params,function(res){
	            	if (res.body.ErrCode == 0){
	            		that.logistics = res.body.Data
	            		that.logisticsLoading = false
	            	} else {
	            		that.openMessage("后勤部门未签收列表获取失败！",'error')
	            	}
	            },function(ex){
	            	console.log('err'+ex)
	            	that.openMessage("网络错误，请重新！ ",'error')
	            })
			},
			//签收操作
			fnSignoff(applyID){
				this.$router.push({ path: '/mealmanagement',query:{'applyID':applyID,'taskID':0,'hasList':false,'pageType':'/sign'}});
			}
		},
		mounted() {
			//获取后勤部门列表
            this.fnGetLogistics()
		}
	}
</script>

<style scoped>
	.logistics-list{
		width: 100%;
		margin-top: 20px;
	}
</style>